#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
#define STDIN
//#define DEBUG

#define MAXN 100
int ans[MAXN];

void initialize() {
    for (int i = 0; i < MAXN; ++i) {
        ans[i] = 0;
    }
}

void process() {
#if defined(DEBUG)
    for (int i = 0; i < MAXN; ++i)
        cout << ans[i] << " ";
    cout << endl;
#endif

    int cnt = 0;

    for (int i = 0; i < MAXN; ) {
        while(ans[i] == 0 && i < MAXN)
            i++;
        ans[i] = 0;
        for (int j = 2*i; j < MAXN; j *= 2){
            if (ans[j] == 1) {
                cnt++, ans[j] = 0;
            }
        }
    }
    cout << cnt << endl;

}

int main() {
#if defined(STDIN)
    fstream cin;
    cin.open("bin/1552.in");
#endif


    int m;
    while(1) {
        cin >> m;
        if (m == -1) {
            break;
        }
        else if (m == 0) {
            process();
            initialize(); 
        }
        else
            ans[m] = 1;
    }
    
    return 0;
}
